package com.example.autocode.strategy;

import cn.hutool.core.lang.Assert;
import com.example.autocode.entity.AutoCodePart;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Author zhangxin
 * @create 2021/12/23 16:49
 */
@Component
@Order(1)
public class PartType01Handle implements PartTypeTemplate {
    @Override
    public String partHandle(AutoCodePart autoCodePart) {
        String inputCharacter = autoCodePart.getInputCharacter();

        Assert.notBlank(inputCharacter, "编码规则存在传入字符类型,当前传入字符为空");

        Assert.isTrue(inputCharacter.length() == autoCodePart.getPartLength(), "传入字符的字符长度不符合规则要求");
        return inputCharacter;
    }
}
